<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./temp.js"></script>
</head>

<body>
    <div id="userBox"></div>
    <script type="text/html" id="tplUser">
        <div>姓名:{{name}}</div>
        <div>年龄:{{age}}</div>
        <div>性别:{{gender}}</div>
        <div>地址:{{address}}</div>
    </script>

</body>

</html>
<script>
    const data = { name: 'lss', age: 30, gender: '女', address: '江西南昌' };
    var htmlStr = template('#tplUser', data)
    document.querySelector('#userBox').innerHTML = htmlStr;
</script>